package demo05

/**
 * @author xiaoZhao
 * @date 2022/6/30
 * @describe
 */
object Test04_Access {
  def main(args: Array[String]): Unit = {
    // 创建对象
    val person = new Person()
    println(person.age)
    println(person.sex)

    println(person.printInfo())

    val worker = new Worker()
    worker.printInfo()

  }
}

// 子类
class Worker extends Person {
  override def printInfo(): Unit ={
//    println(idCard)  error

    name = "王五"
    age = 34
    sex = "女"
    println(s"Worker:  $name $sex $age")
  }
}
